home *** CD-ROM | disk | FTP | other *** search
/ Gamer's Paradise: Czech / Hracuv-raj_Ceske-hry_cd2.bin / Honzovy Šachy 1.0 / zdrojaky / promdlg.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-27  |  2.7 KB  |  103 lines

  1. /*********************************************************/
  2. /* promdlg.c - dialog promeny pesce - jen windows        */
  3. /* 31.12. 2000 Jan Nemec                                 */
  4. /*********************************************************/
  5. #include "volby.h"
  6. #if Typ_Produktu==Win32_Program
  7. #include <windows.h>
  8. #include "winmain.h"
  9. #include "winio.h"
  10. #include "PromDlg.h"
  11. #define NazevTridyDialogu "Dialog prom∞ny"
  12. #define DlgRozmerX 160
  13. #define DlgRozmerY 40
  14. WNDCLASS TridaDialogu;
  15. /* T°φda oken vzhledem podobn²m dialogu */
  16. HWND GlobOtec;
  17. int GlobBarva,GlobVysl;
  18. volatile int Kliknul;
  19.  
  20. static LRESULT wmpaint(HWND hwnd)
  21.  {HDC dc,FDC,PDC;
  22.   PAINTSTRUCT ps;
  23.   int i;
  24.   HBITMAP bm1,bm2;
  25.  
  26.   dc=BeginPaint(hwnd,&ps);
  27.   FDC=CreateCompatibleDC(dc);
  28.   bm1=SelectObject(FDC,hFigury);
  29.   PDC=CreateCompatibleDC(dc);
  30.   bm2=SelectObject(PDC,hPole);
  31.   for (i=0;i<=3;i++)
  32.    {
  33.     WinTiskniPole(dc,PDC,i&1,0,40*i,0);
  34.     WinTiskniFiguru(dc,FDC,GlobBarva ? 5-i : i-5,40*i+2,2);
  35.    }
  36.   EndPaint(hwnd,&ps);
  37.   SelectObject(FDC, bm1);
  38.   SelectObject(PDC, bm2);
  39.   DeleteDC(FDC);
  40.   DeleteDC(PDC);
  41.   return 0;
  42.  }
  43. LRESULT CALLBACK PromenaWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  44.  {switch(uMsg){
  45.     case WM_PAINT: return wmpaint(hwnd);
  46.    case WM_LBUTTONDOWN:
  47.     Kliknul=1;
  48.     GlobVysl=(3-LOWORD(lParam)/40)&3;
  49.     PostMessage(hwnd,WM_CLOSE,0,0);
  50.     return 0;
  51.     case WM_CLOSE: if(Kliknul){
  52.      EnableWindow(GlobOtec,TRUE);
  53.      DestroyWindow(hwnd); 
  54.      }return 0;
  55.    default: return DefWindowProc(hwnd, uMsg, wParam, lParam);
  56.   }
  57.  }
  58.  
  59. void InitTriduDialogu(void)
  60.  {
  61.    TridaDialogu.style=0;
  62.    TridaDialogu.lpfnWndProc=PromenaWinProc;
  63.    TridaDialogu.cbClsExtra=0;
  64.    TridaDialogu.cbWndExtra=0;
  65.    TridaDialogu.hInstance=hInstance;
  66.    TridaDialogu.hIcon=NULL;
  67.    TridaDialogu.hCursor=LoadCursor(NULL,IDC_ARROW);
  68.    TridaDialogu.hbrBackground=GetStockObject(WHITE_BRUSH);
  69.    TridaDialogu.lpszMenuName=NULL;
  70.    TridaDialogu.lpszClassName=NazevTridyDialogu;
  71.    RegisterClass(&TridaDialogu);
  72.   }
  73. #define StylOkna WS_POPUP|WS_CAPTION|WS_DLGFRAME|WS_VISIBLE
  74.  int DialogPromeny(HWND otec, int bily)
  75.  {RECT r,r2;
  76.   MSG msg;
  77.  
  78.   GlobVysl=3;/*Dßma*/
  79.   GlobOtec=otec;
  80.   GlobBarva=bily;
  81.   GetWindowRect(otec,&r);
  82.   r2.left=(r.left+r.right-DlgRozmerX)/2;
  83.   r2.top=(r.top+r.bottom-DlgRozmerY)/2;
  84.   r2.right=r2.left+DlgRozmerX;
  85.   r2.bottom=r2.top+DlgRozmerY;
  86.   AdjustWindowRect(&r2,StylOkna,FALSE);
  87.   CreateWindow (NazevTridyDialogu,"Tak co to bude ?",
  88.                 StylOkna,
  89.                 r2.left,r2.top,r2.right-r2.left+1,r2.bottom-r2.top+1,
  90.                 otec,0, hInstance, NULL);
  91.   EnableWindow(otec,FALSE);
  92.   Kliknul=0;
  93.   while (GetMessage(&msg, NULL, 0, 0)==1)
  94.   {TranslateMessage(&msg);
  95.    DispatchMessage(&msg);
  96.    if (Kliknul) break;
  97.   }
  98.  
  99.   return GlobVysl;
  100.  
  101.  }
  102. #endif
  103.